package pATT.visualize;

import javax.swing.JPanel;

import pATT.BasicAlgorithm.classifiers.tree.J48;
import pATT.profilingAlgorithm.ECTree;
import pATT.profilingAlgorithm.ProfilingAlgorithm;
import pATT.visualize.treeVisualize.PlaceNode2;
import pATT.visualize.treeVisualize.TreeVisualizer;

/**
 * @author
 */
public class ECTreeVisualize extends VisualizeAlgorithm {
	//~ Static fields/initializers -----------------------------------------------------------------
	
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	protected TreeVisualizer tv = null;
	
	//~ Constructors -------------------------------------------------------------------------------
	
	/**
	 * Crea un nuevo objeto ECTreeVisualize.
	 */
	public ECTreeVisualize() {
	}
	
	//~ Methods ------------------------------------------------------------------------------------
	
	/**
	 * Documentacion pendiente.
	 *
	 * @return (documentacion pendiente).
	 */
	@Override
	public boolean canSave() {
		return true;
	}
	/**
	 * Pops up a TreeVisualizer for the classifier from the currently
	 * selected item in the results list
	 * @param dottyString the description of the tree in dotty format
	 * @param treeName the title to assign to the display
	 * @throws Exception
	 */
	@Override
	public JPanel visualizeProfile(ProfilingAlgorithm algorithm)
	throws Exception {
		String dottyString = "";
		dottyString = ((J48) ((ECTree) algorithm).basicAlgorithm()).graph();
		tv = new TreeVisualizer(null, dottyString, new PlaceNode2());
		
		tv.fitToScreen();
		
		tv.setToolTipText("Click here to move the tree");
		
		return tv;
	}

	@Override
	public JPanel getPanelVisualize() {
		return tv;
	}
}
